home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 25 / Cream of the Crop 25.iso / doom / quake_ad.zip / HIPQW.ZIP / SRC / HIP_PART.QC < prev    next >
Text File  |  1997-01-16  |  7KB  |  308 lines

  1. /* Particle effects QuickC program
  2.    By Jim Dose'  9/19/96
  3.    Copyright (c)1996 Hipnotic Interactive, Inc.
  4.    All rights reserved.
  5.    Do not distribute.
  6. */
  7.  
  8. //float START_OFF = 1;
  9. float USE_COUNT = 1;
  10.  
  11. void () particlefield_XZ =
  12.     {
  13.     local vector pos;
  14.    local vector start;
  15.    local vector end;
  16.  
  17.    if ( ( self.spawnflags & USE_COUNT ) &&
  18.       ( counter_GetCount( other ) != self.cnt ) )
  19.       {
  20.       return;
  21.       }
  22. //   dprint( "XZ\n" );
  23.  
  24.    self.ltime = time + 0.25;
  25.    if ( self.noise )
  26.       {
  27.       sound(self, CHAN_VOICE, self.noise, 1, ATTN_NORM);
  28.       }
  29.  
  30.    // Only show particles if client is visible.
  31.    // This helps to keep network traffic down to a minimum.
  32.    if (!checkclient() )
  33.       return;
  34.  
  35.    start = self.dest1 + self.origin;
  36.    end   = self.dest2 + self.origin;
  37.    pos_y = start_y;
  38.    pos_z = start_z;
  39.    while( pos_z <= end_z )
  40.         {
  41.       pos_x = start_x;
  42.       while( pos_x <= end_x )
  43.             {
  44.          particle ( pos, '0 0 0', self.color, self.count );
  45.          pos_x = pos_x + 16;
  46.             }
  47.       pos_z = pos_z + 16;
  48.         }
  49.     };
  50.  
  51. void () particlefield_YZ =
  52.     {
  53.     local vector pos;
  54.    local vector start;
  55.    local vector end;
  56.  
  57.    if ( ( self.spawnflags & USE_COUNT ) &&
  58.       ( counter_GetCount( other ) != self.cnt ) )
  59.       {
  60.       return;
  61.       }
  62.  
  63. //   dprint( "YZ: " );
  64. //   dprint( vtos( self.dest1 ) );
  65. //   dprint( " - " );
  66. //   dprint( vtos( self.dest2 ) );
  67. //   dprint( "\n" );
  68.    self.ltime = time + 0.25;
  69.    if ( self.noise )
  70.       {
  71.       sound(self, CHAN_VOICE, self.noise, 1, ATTN_NORM);
  72.       }
  73.  
  74.    // Only show particles if client is visible.
  75.    // This helps to keep network traffic down to a minimum.
  76.    if (!checkclient() )
  77.       return;
  78.  
  79.    start = self.dest1 + self.origin;
  80.    end   = self.dest2 + self.origin;
  81.    pos_x = start_x;
  82.    pos_z = start_z;
  83.    while( pos_z < end_z )
  84.         {
  85.       pos_y = start_y;
  86.       while( pos_y < end_y )
  87.             {
  88.          particle ( pos, '0 0 0', self.color, self.count );
  89.             pos_y = pos_y + 16;
  90.             }
  91.         pos_z = pos_z + 16;
  92.         }
  93.     };
  94.  
  95. void () particlefield_XY =
  96.     {
  97.     local vector pos;
  98.    local vector start;
  99.    local vector end;
  100.  
  101.    if ( ( self.spawnflags & USE_COUNT ) &&
  102.       ( counter_GetCount( other ) != self.cnt ) )
  103.       {
  104.       return;
  105.       }
  106.  
  107. //   dprint( "XY\n" );
  108.    self.ltime = time + 0.25;
  109.    if ( self.noise )
  110.       {
  111.       sound(self, CHAN_VOICE, self.noise, 1, ATTN_NORM);
  112.       }
  113.  
  114.    // Only show particles if client is visible.
  115.    // This helps to keep network traffic down to a minimum.
  116.    if (!checkclient() )
  117.       return;
  118.  
  119.  
  120.    start = self.dest1 + self.origin;
  121.    end   = self.dest2 + self.origin;
  122.    pos_x = start_x;
  123.    pos_z = start_z;
  124.    while( pos_x < end_x )
  125.         {
  126.       pos_y = start_y;
  127.       while( pos_y < end_y )
  128.             {
  129.          particle ( pos, '0 0 0', self.color, self.count );
  130.             pos_y = pos_y + 16;
  131.             }
  132.         pos_x = pos_x + 16;
  133.         }
  134.     };
  135.  
  136. void () particlefield_touch =
  137.     {
  138.    if ( !self.dmg )
  139.       return;
  140.  
  141.    if ( time > self.ltime)
  142.       return;
  143.  
  144.     if (time < self.attack_finished)
  145.         return;
  146.     self.attack_finished = time + 0.5;
  147.     T_Damage (other, self, self, self.dmg);
  148.    };
  149.  
  150. /*QUAKED func_particlefield (0 .5 .8) ? USE_COUNT
  151. Creates a brief particle flash roughly the size of the defining
  152. brush each time it is triggered.
  153.  
  154. USE_COUNT when the activator is a func_counter, the field will only
  155.    activate when count is equal to "cnt".  Same as using a func_oncount
  156.    to trigger.
  157.  
  158. "cnt" is the count to activate on when USE_COUNT is set.
  159. "color" is the color of the particles.  Default is 192 (yellow).
  160. "count" is the density of the particles.  Default is 2.
  161. "noise" is the sound to play when triggered.  Do not use a looping sound here.
  162. "dmg" is the amount of damage to cause when touched.
  163. */
  164.  
  165. void() func_particlefield =
  166.     {
  167.    if ( !self.color )
  168.        {
  169.       self.color = 192;
  170.        }
  171.    if ( self.count == 0 )
  172.        {
  173.       self.count = 2;
  174.        }
  175.    self.classname = "particlefield";
  176.    self.solid = SOLID_NOT;
  177.    self.movetype = MOVETYPE_NONE;
  178.    setmodel (self, self.model);
  179.    self.model = string_null;
  180.  
  181.    self.origin = ( self.mins + self.maxs ) * 0.5;
  182.    setorigin (self, self.origin);
  183.    self.dest = self.maxs - self.mins - '16 16 16';
  184.    self.dest1 = self.mins + '8 8 8' - self.origin;
  185.    self.dest2 = self.maxs + '7.9 7.9 7.9' - self.origin;
  186.    setsize (self, self.mins, self.maxs);
  187.    self.touch = particlefield_touch;
  188. //   dprint( vtos( self.dest ) );
  189. //   dprint( "  " );
  190.    if ( self.dest_x > self.dest_z )
  191.         {
  192.       if ( self.dest_y > self.dest_z )
  193.             {
  194. //         dprint( "XY1 - " );
  195. //         dprint( ftos( self.cnt ) );
  196. //         dprint( "\n" );
  197.          self.use = particlefield_XY;
  198.          self.dest1_z = ( self.dest1_z + self.dest2_z ) / 2;
  199.             }
  200.         else
  201.             {
  202. //         dprint( "XZ1 - " );
  203. //         dprint( ftos( self.cnt ) );
  204. //         dprint( "\n" );
  205.          self.use = particlefield_XZ;
  206.          self.dest1_y = ( self.dest1_y + self.dest2_y ) / 2;
  207.             }
  208.         }
  209.     else
  210.         {
  211.       if ( self.dest_y > self.dest_x )
  212.          {
  213. //         dprint( "YZ2 - " );
  214. //         dprint( ftos( self.cnt ) );
  215. //         dprint( "\n" );
  216.          self.use = particlefield_YZ;
  217.          self.dest1_x = ( self.dest1_x + self.dest2_x ) / 2;
  218.             }
  219.         else
  220.             {
  221. //         dprint( "XZ2 - " );
  222. //         dprint( ftos( self.cnt ) );
  223. //         dprint( "\n" );
  224.          self.use = particlefield_XZ;
  225.          self.dest1_y = ( self.dest1_y + self.dest2_y ) / 2;
  226.             }
  227.         }
  228.  
  229.    if ( self.noise )
  230.       {
  231.       precache_sound( self.noise );
  232.       }
  233.    self.ltime = time;
  234.    };
  235.  
  236. void () blocker_touch =
  237.     {
  238.    if ( !self.dmg )
  239.       return;
  240.  
  241.     if (time < self.attack_finished)
  242.         return;
  243.     self.attack_finished = time + 0.5;
  244.     T_Damage (other, self, self, self.dmg);
  245.    };
  246.  
  247. void () blocker_use =
  248.     {
  249.    if ( !self.state )
  250.       {
  251.       self.state = 1;
  252.       setorigin( self, self.origin - '8000 8000 8000' );
  253.       sound(self, CHAN_VOICE, self.noise1, 1, ATTN_NORM);
  254.       }
  255.    else
  256.       {
  257.       self.state = 0;
  258.       setorigin( self, self.origin + '8000 8000 8000' );
  259.       sound(self, CHAN_VOICE, self.noise, 1, ATTN_NORM);
  260.       }
  261.    };
  262.  
  263. /*QUAKED func_togglewall (0 .5 .8) ? START_OFF
  264. Creates a invisible wall that can be toggled on and off.
  265.  
  266. START_OFF wall doesn't block until triggered.
  267.  
  268. "noise" is the sound to play when wall is turned off.
  269. "noise1" is the sound to play when wall is blocking.
  270. "dmg" is the amount of damage to cause when touched.
  271. */
  272.  
  273. void() func_togglewall =
  274.     {
  275.    self.classname = "togglewall";
  276.    self.movetype = MOVETYPE_PUSH;
  277.    self.mdl = self.model;
  278.    setmodel (self, self.model);
  279.    setsize (self, self.mins, self.maxs);
  280.    setorigin (self, self.origin);
  281.    self.touch = blocker_touch;
  282.    self.use = blocker_use;
  283.    if ( !self.noise )
  284.       {
  285.       self.noise = ("misc/null.wav");
  286.       }
  287.    if ( !self.noise1 )
  288.       {
  289.       self.noise1 = ("misc/null.wav");
  290.       }
  291.  
  292.    precache_sound( self.noise );
  293.    precache_sound( self.noise1 );
  294.  
  295.    self.solid = SOLID_BSP;
  296.    self.model = string_null;
  297.    if ( self.spawnflags & START_OFF )
  298.       {
  299.       self.state = 0;
  300.       setorigin( self, self.origin + '8000 8000 8000' );
  301.       }
  302.    else
  303.       {
  304.       self.state = 1;
  305.       sound(self, CHAN_VOICE, self.noise1, 1, ATTN_NORM);
  306.       }
  307.    };
  308.